package com.bootcamp.javase2.stream;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

/**
 * @program: StreamCode
 * @description:
 * @author: Keyu Li
 * @create: 2021-09-11 14:23
 **/

public class ReverseTxt {
    public static void main(String[] args) throws IOException {
        // create object
        BufferedReader breader = new BufferedReader(new FileReader("order.java"));
        FileWriter fwriter = new FileWriter("reversed.java");
        // while loop to the end
        String line;
        while ((line = breader.readLine())!=null){
            char[] arrays = line.toCharArray();
            for (int i = arrays.length-1; i >=0; i--) {
                fwriter.write(arrays[i]);
            }
            fwriter.write(System.lineSeparator());
        }
        // close
        breader.close();
        fwriter.close();
    }
}
